package com.byf.search.controller;


import com.alibaba.fastjson2.JSONArray;
import com.byf.common.core.domain.Result;
import com.byf.search.common.domain.SkuEsModel;
import com.byf.search.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;


@RestController
@RequestMapping("/es")
public class EsSaveController {


    @Autowired
    private ProductService productService;


    /**
     * 批量添加es
     * @param skuEsModelList
     * @return
     * @throws IOException
     */
    @PostMapping("/save")
    public Result productStatusUp(@RequestBody String skuEsModelList) throws IOException {
        List<SkuEsModel> list = JSONArray.parseArray(skuEsModelList, SkuEsModel.class);

        productService.productStatsUp(list);


        return Result.success();
    }
}
